<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

abstract class Admin extends CI_Controller
{
    abstract public function getPage();

    public function getMoreData()
    {
        return array();
    }

    public function index($message = '')
    {
        $page = $this->getPage();

        $this->lang->load('common', $this->session->userdata('language'));
        if (file_exists('application/language/' . $this->session->userdata('language') . '/' . $page . '_lang.php')) {
            $this->lang->load($page, $this->session->userdata('language'));
        }

        if (!file_exists('application/views/' . $page . '.php')) {
            show_404();
        }

        $data = $this->getMoreData();

        $data['title'] = ucfirst($page);
        $data['message'] = $message;
        $data['fullName'] = $this->session->userdata('fullName');
        $data['language'] = $this->session->userdata('language');

        $this->load->view('layout/admin/include', $data);
        $this->load->view('layout/admin/common-header', $data);
        $this->load->view($page, $data);
        $this->load->view('layout/admin/common-footer', $data);
        $this->load->view('layout/admin/footer', $data);
    }
}